#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
int calPoints(vector<string>& operations) {
    vector<int> scores; // 用vector模拟栈来存储有效得分
    
    for (const string& op : operations) {
        if (op == "+") {
            // 前两轮得分之和
            int score1 = scores[scores.size() - 1];
            int score2 = scores[scores.size() - 2];
            scores.push_back(score1 + score2);
        }
        else if (op == "D")
            scores.push_back(scores.back() * 2);
        else if (op == "C")
            scores.pop_back();
        else 
            scores.push_back(atoi(op.c_str()));
    }
    int total = 0;
    for (int score : scores)
        total += score;
    return total;
}
int main(){
	vector<string> v={"5","2","C","D","+"};
	cout<<calPoints(v)<<endl;
	return 0;
}

